$(function() {
    $('input[type=submit]').bind('click', function() {
        $(this).hide();
    });

    //for /picklocation and /pickroute pages, allow a click on the list element to trigger the hyperlink in it
    $('ul#picklocation li, ul#pickroute li').bind('click', function() {
        window.location = $(this).find('a').attr('href');
    });

    $('input#deleteaccount').bind('click', function() {
        if(!confirm('Are you sure you want to close your account?')) {
            $(this).show();
            return false;
        }
    });

    //fadeout error and success messages after 3 seconds
    $('document').ready(function() {
        $('div.success:not(.noclose), div.error:not(.noclose)').delay(3000).slideUp('slow');
    });

    //editroute + addroute change route type preview
    $('select[name="type_id"]').change(function() {
        var type = $(this).find(':selected').attr('data-type');
        $('img.routetype').attr('class', 'routetype ' + type);
    });

    //checkin screen block count focus
    $('input[name="blocks"]').focus(function() {
        this.select();
        $('input[type="radio"][value="1"]').attr('checked', true);
    });
});
